package com.zsrt.java.day20161226.cg.demo02;

import java.util.Scanner;

public class TestCal02 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println("输入第一个数");
		int a = sc.nextInt();
		System.out.println("输入符号");
		String flag = sc.next();
		System.out.println("输入第二个数");
		int b = sc.nextInt();
		sc.close();
		
		cal(a, flag, b);
		
	}
	/**
	 * 求两个数的加减乘除以及求模的算法
	 * @param int a 
	 * @param int b 
	 * @param String flag
	 * @return cal() 
	 */
	
	public static void cal(int a,String flag,int b){
		while(true){
			
			if (flag.equals("+")) {
				System.out.println(a+"+"+b+"="+(a+b));
				break;
			}else if(flag.equals("-")){
				System.out.println(a+"-"+b+"="+(a-b));			
				break;
				
			}else if(flag.equals("*")){
				System.out.println(a+"*"+b+"="+(a*b));			
				break;
				
			}else if(flag.equals("/")){
				System.out.println(a+"/"+b+"="+(a/b));			
				break;
				
			}else if(flag.equals("%")){
				System.out.println(a+"%"+b+"="+(a%b));	
				break;
				
			}else if(flag.equals("off")){
				break;
			}
		}
	}
}
